// src/utils/navigation.ts - 纯前端导航模拟
// 添加导航参数接口定义
interface NavigationParams {
    // 简化参数定义
    _lat: number;
    _lng: number;
    _name?: string;
}

export const simulateNavigation = async (
    _from: { lng: number; lat: number }, 
    _to: { lng: number; lat: number },
    onProgress?: (progress: number) => void
  ) => {
    return new Promise<void>((resolve) => {
      let progress = 0
      
      const interval = setInterval(() => {
        progress += 5
        if (onProgress) {
          onProgress(Math.min(progress, 100))
        }
        
        if (progress >= 100) {
          clearInterval(interval)
          resolve()
        }
      }, 200)
    })
  }
  
  // 模拟唤起手机导航
  export const openNativeNavigation = (params: NavigationParams) => {
    // 解构参数
    const { _lat: lat, _lng: lng, _name: name = '目的地' } = params;
    // 尝试唤起高德地图
    const amapUrl = `amapuri://route/plan/?dlat=${lat}&dlon=${lng}&dname=${encodeURIComponent(name)}&dev=0&t=0`
    
    // 创建唤起链接
    const link = document.createElement('a')
    link.href = amapUrl
    link.click()
    
    // 如果唤起失败，显示提示
    setTimeout(() => {
      alert(`无法唤起地图应用，请手动导航到: ${name}`)
    }, 1000)
  }